package com.itheima.demo.demo10;
//项目根路径下有text.txt文件，内容如下：
//	我爱黑马
//	123456
//利用IO流的知识读取text.txt文件的内容反转后写入text1.txt文件中，内容如下：
//	123456
//我爱黑马

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

public class Test_5 {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new FileReader("D:\\texQt.txt"));
        ArrayList<String>list=new ArrayList<>();
        String len="";
        while ((len=br.readLine())!=null){
            list.add(len);
        }
        System.out.println(list);
        Collections.reverse(list);
        System.out.println(list);
        br.close();
        BufferedWriter bw=new BufferedWriter(new FileWriter("D:\\tex1Qt.txt"));
        for (int i = 0; i < list.size(); i++) {
            bw.write(list.get(i));
            bw.newLine();
        }
        bw.close();
    }
}
